package cn.virens.util.poi.read;

import java.util.ArrayList;
import java.util.List;

import org.apache.poi.ss.usermodel.Row;

public class RowObject {
	private int rowIndex;

	private List<CellObject<?>> cellObjects = new ArrayList<>();

	public RowObject(int rowIndex) {
		this.rowIndex = rowIndex;
	}

	public int getRowIndex() {
		return rowIndex;
	}

	public void setRowIndex(int rowIndex) {
		this.rowIndex = rowIndex;
	}

	public List<CellObject<?>> getCellObjects() {
		return cellObjects;
	}

	public <D> void addCellObject(CellReader<D> feild, Row row) {
		this.addCellObject(feild.read(row, this));
	}

	public <D> void addCellObject(CellObject<D> cellObject) {
		this.cellObjects.add(cellObject);
	}

	public <D> CellObject<D> createObject(CellReader<D> readCell) {
		return new CellObject<>(readCell, this);
	}
}
